package com.catazy.wanandroid.common_base.net.interceptor

import okhttp3.Interceptor
import okhttp3.Response

/**
 * 作者: Tao
 * 日期: 2024/4/10
 * 时间: 13:33
 * 描述: 基础参数拦截器
 * 拦截请求，添加基础参数
 */
class BasicParamsInterceptor:Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val originalRequest = chain.request()
        val originalHttpUrl = originalRequest.url
        val url = originalHttpUrl.newBuilder().apply {
            addQueryParameter("udid", "123456")
            addQueryParameter("vc", "1")
            addQueryParameter("vn", "1.0")
            addQueryParameter("size", "1080X1920")
            addQueryParameter("deviceModel", "MI6")
            addQueryParameter("first_channel", "eyepetizer")
            addQueryParameter("last_channel", "eyepetizer")
            addQueryParameter("system_version_code", "28")
        }.build()
        val request = originalRequest.newBuilder().url(url).method(originalRequest.method,
            originalRequest.body
        ).build()
        return chain.proceed(request)
    }
}